package icu.d4peng.cloud.common.mvc.properties;

import com.alibaba.fastjson.JSON;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author d4peng
 * @version 1.0.0
 * @date 2021-12-30 11:25
 * @description MvcProperties:
 */
@ConfigurationProperties(prefix = MvcProperties.PREFIX)
public class MvcProperties {
    /**
     * 前缀
     */
    public static final String PREFIX = "roc.mvc";
    /**
     * 是否开启:默认开启
     */
    private boolean enabled = true;
    /**
     * 是否开启默认的错误处理
     */
    private boolean enableDefaultErrorsHandler = true;
    /**
     * 是否开启默认的校验策略
     */
    private boolean enableDefaultValidRule = true;
    /**
     * 全局时间格式化正则表达式
     */
    private String globalTimeFormatRegex = "yyyy-MM-dd HH:mm:ss";

    public boolean isEnabled() {
        return enabled;
    }

    public MvcProperties setEnabled(boolean enabled) {
        this.enabled = enabled;
        return this;
    }

    public boolean isEnableDefaultErrorsHandler() {
        return enableDefaultErrorsHandler;
    }

    public MvcProperties setEnableDefaultErrorsHandler(boolean enableDefaultErrorsHandler) {
        this.enableDefaultErrorsHandler = enableDefaultErrorsHandler;
        return this;
    }

    public boolean isEnableDefaultValidRule() {
        return enableDefaultValidRule;
    }

    public MvcProperties setEnableDefaultValidRule(boolean enableDefaultValidRule) {
        this.enableDefaultValidRule = enableDefaultValidRule;
        return this;
    }

    public String getGlobalTimeFormatRegex() {
        return globalTimeFormatRegex;
    }

    public MvcProperties setGlobalTimeFormatRegex(String globalTimeFormatRegex) {
        this.globalTimeFormatRegex = globalTimeFormatRegex;
        return this;
    }

    @Override
    public String toString() {
        return JSON.toJSONString(this);
    }
}